package com.xiaoKe.zhonghzu.ui.onClick;

import android.os.SystemClock;
import android.view.View;

/**
 * @ProjectName : app
 * @Author : Shijingna
 * @Time : 2022/12/19 10:40 上午
 * @Description : 工具类——防止重复点击的 onClickListener
 */
public    abstract  class NoDoubleClickListener implements View.OnClickListener {
    public static final int MIN_CLICK_DELAY_TIME = 1000;
    private long lastClickTime = 0;

    @Override
    public void onClick(View v) {
        long currentTime = SystemClock.elapsedRealtime();
        if (currentTime - lastClickTime > MIN_CLICK_DELAY_TIME) {
            lastClickTime = currentTime;
            onNoDoubleClick(v);
        }
    }
    protected abstract void onNoDoubleClick(View view);


}